package com.zking.utils;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class DateUtil {

    public List<String> getWeekDay(){
        List<String> all_Day = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String today = formatter.format(calendar.getTime());
        for (int i=0;i<8;i++){
            calendar.add(Calendar.DAY_OF_MONTH, 1);
            today = formatter.format(calendar.getTime());
            all_Day.add(today);
        }
        return all_Day;
    }

    public static String getCurrentTime(){
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String currentDate = sdf.format(d);
        return currentDate;
    }

    public static  String getTime(){
        Date d = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String currentDate = sdf.format(d);
        return currentDate;
    }

    public String getEightDay(){
        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        calendar.add(Calendar.DAY_OF_MONTH, 8);
        String today = formatter.format(calendar.getTime());
        return today;
    }

    public static void main(String[] args) {
//        DateUtil dateUtil = new DateUtil();
//        System.out.println(dateUtil.getWeekDay());
//        System.out.println(dateUtil.getEightDay());

        String currentTime = DateUtil.getCurrentTime();
        System.out.println("currentTime = " + currentTime);

        String testDate = "2020-08-27 14:00-15:00";
        String dateSub = testDate.substring(17,22);
        System.out.println("dateSub = " + dateSub);

    }
}
